import util.TreeNode;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by losor on 2017/3/16.
 */
public class _257_BinaryTreePaths {
    public List<String> binaryTreePaths(TreeNode root) {
        List<String> list = new ArrayList<>();
        if (root == null){
            return list;
        }
        putString(root,list,root.val+"");
        return list;
    }

    public void putString(TreeNode root,List<String> list, String s){
        if (root.left == null && root.right == null){
            list.add(s);
        }
        if (root.left!= null)
        putString(root.left,list,s+"->"+root.left.val);
        if (root.right!= null)
        putString(root.right,list,s+"->"+root.right.val);
    }
}
